<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
</head>

<body>
	<div align="center">
		<form action="show" method="post">
			<p>
				电影名:<input type="text" id="uname" name="uname" value="${uname}" />
				主演:<input type="text" id="actstar" name="actstar" value="${actstar}" />
				<input type="submit" value="提交" />
			</p>

		</form>
		<table border="1">
			<tr>
				<td>编号</td>
				<td>电影名</td>
				<td>主演</td>
				<td>导演</td>
				<td>票价</td>
				<td>上映时间</td>
				<td>简介</td>
				<td>点赞数</td>
				<td>众评</td>
				<td>操作</td>
			</tr>
			<c:forEach items="${pageData.list}" var="f">
				<tr>
					<td class="tds">${f.id}</td>
					<td>${f.uname}</td>
					<td>${f.actstar}</td>
					<td>${f.director}</td>
					<td>${f.price}</td>
					<td><fmt:formatDate value="${f.releaseDate}"
							pattern="yyyy年MM月dd日" /></td>
					<td>${f.brief}</td>
					<td>${f.fabulous}</td>
					<td>${f.content}</td>
					<td><input type="button" uid="${f.id}" class="btn" value="点赞">
						<a href="toadd?id=${f.id}">众评</a></td>
				</tr>
			</c:forEach>
		</table>
		<c:if test="${pageData.hasPreous}">
			<a href="show?pageIndex=1&&uname=${uname}&&actstar=${actstar}">首页</a>
			<a href="show?pageIndex=${pageData.pageIndex-1}&&uname=${uname}&&actstar=${actstar}">上一页</a>
		</c:if>
		<c:if test="${not pageData.hasPreous}">
			<a href="show?pageIndex=1&&uname=${uname}&&actstar=${actstar}">首页</a>
			<a href="show?pageIndex=1&&uname=${uname}&&actstar=${actstar}">上一页</a>
		</c:if>
		<c:if test="${pageData.hasNext}">
			<a href="show?pageIndex=${pageData.pageIndex+1}&&uname=${uname}&&actstar=${actstar}">下一页</a>
			<a href="show?pageIndex=${pageData.totalPageCount}&&uname=${uname}&&actstar=${actstar}">尾页</a>
		</c:if>
		<c:if test="${not pageData.hasNext}">
			<a href="show?pageIndex=${pageData.totalPageCount}&&uname=${uname}&&actstar=${actstar}">下一页</a>
			<a href="show?pageIndex=${pageData.totalPageCount}&&uname=${uname}&&actstar=${actstar}">尾页</a>
		</c:if>
	</div>
</body>
</html>
<script src="statics/jquery-1.8.3.min.js"></script>
<script>
	$(function() {
		$(".btn").click(function() {
			var id = $(this).attr("uid");
			$.ajax({
				url : "checkadd",
				TYPE : "GET",
				data : {
					id : id
				},
				dataType : "JSON",
				success : function(result) {
					if (result == 1) {
						alert("点赞成功!");
					} else {
						alert("点赞失败!");
					}
				}
			})
		})
	})
</script>